<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

//路由-》控制器
Route::get('memberinfo/info', 'MemberInfoController@info');
Route::get('student/index/{id?}', ['uses' => 'StudentController@index']);
Route::get('add', ['uses' => 'StudentController@add']);
Route::get('update', ['uses' => 'StudentController@update']);
Route::get('del', ['uses' => 'StudentController@del']);
Route::get('query', ['uses' => 'StudentController@query']);
Route::get('group', ['uses' => 'StudentController@groupFunc']);
Route::get('orm', ['uses' => 'StudentController@orm']);
Route::get('orm2', ['uses' => 'StudentController@orm2']);
Route::get('ormUpdate', ['uses' => 'StudentController@ormUpdate']);
Route::get('blade', ['uses' => 'StudentController@blade']);
Route::get('route-test', ['as' => 'route-test', 'uses' => 'StudentController@routeTest']);
Route::get('re', ['uses' => 'StudentController@request1']);
Route::get('response', ['uses' => 'StudentController@response']);
Route::get('redis', ['uses' => 'StudentController@redis']);

//路由群组  引入web中间件 app\Http\Kernel.php
Route::group(['middleware' => 'web'], function(){
    Route::get('session',[
        'as' => 'session',
        'uses' => 'StudentController@session'
    ]);
});

//middleware
//宣传
Route::get('activity', ['uses' => 'StudentController@activity']);
//互动页面
Route::group(['middleware' => 'activity'], function(){
    Route::get('activity1', ['uses' => 'StudentController@activity1']);
    Route::get('activity2', ['uses' => 'StudentController@activity2']);
});
/*Route::get('member/info', ['uses' => 'MemberController@info']);
//别名
Route::get('member/info', [
    'uses' => 'MemberController@info',
    'as' => 'memberinfo',
]);
//路由传参  验证
Route::get('member/{id}', ['uses' => 'MemberController@info'])
->where('id', '[0-9]+');*/


/*//基础路由
Route::post('basic1', function () {
    return 'post';
});

Route::get('basic2', function () {
    return 'get';
});

//多请求
Route::match(['get', 'post'], 'multy1', function () {
    return 'multy1-special';
});//响应指定类型

Route::any('multy2', function () {
    return 'multy2-any';
});//响应所有的请求

//路由参数
Route::get('user/{id}', function ($id) {
    return 'param-id-'.$id;
});
//参数可选
Route::get('user/{name?}', function ($name='name') {
    return 'param-name-'.$name;
});

//正则
Route::get('user/{name?}', function ($name = 'name') {
    return 'param-preg-' . $name;
})->where('name', '[A-Za-z]+');
//正则多参数
Route::get('user/{id}/{name?}', function ($id = 11, $name = 'name') {
    return 'param-preg-name-id-' . $id.'-'.$name;
})->where(['name'=>'[A-Za-z]+','id'=>'[0-9]+',]);


//路由别名
Route::get('user/mcenter',['as'=>'center',function(){
    return route('center');
}]);

//路由群组
Route::group(['prefix' => 'member'], function(){

    Route::get('user/center',['as'=>'center',function(){
        return route('center');
    }]);

    Route::any('multy2', function () {
        return 'member-multy2-any';
    });//响应所有的请求
});

//路由-视图
Route::get('view', function () {
    return view('view');
});*/